// plugins/modalPlugin.ts
import { App } from 'vue'
import GlobalModal from './GlobalModal.vue'
import { modalService } from './modalService'

// 扩展 Vue 全局属性
declare module '@vue/runtime-core' {
  interface ComponentCustomProperties {
    $modal: typeof modalService
  }
}

export default {
  install(app: App) {
    // 注册全局组件
    app.component('GlobalModal', GlobalModal)

    // 添加到全局属性
    app.config.globalProperties.$modal = modalService

    // 提供注入
    app.provide('$modal', modalService)
  },
}
